package com.myrpc.common;

import java.util.List;

import org.msgpack.MessagePack;
import org.msgpack.template.Templates;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToMessageDecoder;

public class MyMessageDecoder  extends MessageToMessageDecoder<ByteBuf>   {
	final MessagePack msgpack = new MessagePack();
	@Override
	protected void decode(ChannelHandlerContext ctx, ByteBuf msg, List<Object> out) throws Exception {
		
		byte[] array = new byte[msg.readableBytes()];
		
		msg.readBytes(array);
		
		out.add(msgpack.read(array,Templates.TString));
		
	}
	
	

}
